﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Web.Security;

namespace Alogient.Cameleon.Community.Blog.Items
{
    [Serializable]
    [XmlRoot("Blog")]
    [XmlType("Blog")]
    public class CMBlog : IAlerte
    {
        #region Fields

        private List<CMArticle> articles = null;
        private List<MembershipUser> moderators = null;

        #endregion Fields

        #region Constructor
        /// <summary>
        /// Default constructor
        /// </summary>
        internal CMBlog()
        {
        }

        #endregion Constructor

        #region Properties

        /// <summary>
        /// Get or Set Blog Id
        /// </summary>
        [XmlAttribute]
        public int BlogID { get; set; }

        /// <summary>
        /// Get or Set culture code
        /// </summary>
        [XmlAttribute]
        public string CultureCode { get; set; }

        /// <summary>
        /// Get or Set the creation date
        /// </summary>
        [XmlAttribute]
        public DateTime CreationDate { get; set; }

        /// <summary>
        /// Get or Set Last modified date
        /// </summary>
        [XmlAttribute]
        public DateTime LastModified { get; set; }

        /// <summary>
        /// Get or Set owner Id
        /// </summary>
        [XmlAttribute]
        public Guid OwnerID { get; set; }

        /// <summary>
        /// owner first name
        /// </summary>
        [XmlAttribute]
        public string OwnerFirstName { get; set; }

        /// <summary>
        /// owner last name
        /// </summary>
        [XmlAttribute]
        public string OwnerLastName { get; set; }

        /// <summary>
        /// Get or Set the blog title
        /// </summary>
        [XmlAttribute]
        public string Title { get; set; }

        /// <summary>
        /// Get or Set the blog text
        /// </summary>
        [XmlAttribute]
        public string Text { get; set; }

        /// <summary>
        /// Articles of a blog
        /// </summary>
        [XmlAttribute]
        public List<CMArticle> Articles
        {
            get { return this.articles ?? (this.articles = this.GetArticles()); }
        }

        /// <summary>
        /// List of moderators of a blog
        /// </summary>
        [XmlAttribute]
        public List<MembershipUser> Moderators
        {
            get { return this.moderators ?? (this.moderators = this.GetModerators()); }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Get an article by his ID
        /// </summary>
        /// <param name="articleID">Article ID</param>
        /// <returns>An article</returns>
        public CMArticle GetArticle(int articleID)
        {
            throw new NotImplementedException("Not implemented");
        }

        /// <summary>
        /// Get this blog articles
        /// </summary>
        /// <returns></returns>
        public List<CMArticle> GetArticles()
        {
            return this.GetArticles(this.CultureCode);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cultureCode"></param>
        /// <returns></returns>
        private List<CMArticle> GetArticles(string cultureCode)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        /// <summary>
        /// Get this blog articles for tag name.
        /// </summary>
        /// <returns></returns>
        public List<CMArticle> GetArticlesForTag(string tag)
        {
            return this.GetArticlesForTag(tag, this.CultureCode);
        }

        /// <summary>
        /// Get this blog articles for tag name.
        /// </summary>
        /// <param name="cultureCode"></param>
        /// <returns></returns>
        private List<CMArticle> GetArticlesForTag(string tag, string cultureCode)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="title"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public CMArticle AddArticle(string title, string teaser, string text, string author)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public List<CMArticle> RemoveArticle(CMArticle article)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<MembershipUser> GetModerators()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="moderator"></param>
        /// <returns></returns>
        public List<MembershipUser> AddModerator(MembershipUser moderator)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="moderator"></param>
        /// <returns></returns>
        public List<MembershipUser> RemoveModerator(MembershipUser moderator)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }

        #region IAlerte Members
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<MembershipUser> GetSuscribers()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        public MembershipUser GetSuscriber(MembershipUser suscriber)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="suscriber"></param>
        /// <returns></returns>
        public List<MembershipUser> AddSuscriber(MembershipUser suscriber)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Suscriber"></param>
        /// <returns></returns>
        public List<MembershipUser> RemoveSuscriber(MembershipUser suscriber)
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        #endregion IAlerte Members

        /// <summary>
        /// Save the blog to the database
        /// </summary>
        public bool Save()
        {
            throw new NotImplementedException("Not implemented"); // TODO
        }
        #endregion
    }
}
